package com.teemo.dp.composite.demo1;

import cn.hutool.json.JSONUtil;

/**
 * @author Teemo
 */
public class Demo {
    public static void main(String[] args) {
        Person root = new Person();
        root.setName("父");

        Person child1 = new Person();
        child1.setName("子1");
        Person child2 = new Person();
        child2.setName("子2");

        root.getChildren().add(child1);
        root.getChildren().add(child2);

        Person grandson = new Person();
        grandson.setName("孙");
        child2.getChildren().add(grandson);

        String jsonStr = JSONUtil.toJsonStr(root);
        System.out.println(jsonStr);
    }
}
